﻿using MovingChame.WindowsStoreApp.Common;
using MovingChameLibrary.Models;
using MovingChameLibrary.Models.Action;
using MovingChameLibrary.ViewModels;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace MovingChame.WindowsStoreApp.UIModule
{
    public sealed partial class PersonalTourPage : LayoutAwarePage
    {
        private PersonalTourGroupViewModel _viewModel;
        public PersonalTourGroupViewModel ViewModel
        {
            get { return this._viewModel; }
            set
            {
                this._viewModel = value;
                this.DataContext = value;
            }
        }

        public PersonalTourPage()
        {
            this.InitializeComponent();
        }

        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            ViewModel = new PersonalTourGroupViewModel();
        }

        private void Header_Click(object sender, RoutedEventArgs e)
        {
            var group = (sender as FrameworkElement).DataContext;
            this.Frame.Navigate(typeof(TourSelectionPage), ((TourGroup)group).Id);
        }

        private void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Tour tour = (Tour)e.ClickedItem;
            this.Frame.Navigate(typeof(TourOverviewPage), tour.Id);
        }
    }
}